< previous page page_214 next page >

Page 214
But what about the WINVER constant? What value should you assume is present when translating structures to Visual Basic? This is important to consider because, if you use a later version of the structure, it will fail to work on older-version operating systems. A C++ programmer sets the value of this constant to a value equal to the oldest operating system the application should support before compiling his application. For Visual Basic you should choose the value before creating your structure declarations.
The WINVER variable is a 2-byte number where the high byte is the major version of Windows. It will be 3 for Windows NT 3.x, 4 for Windows 95 and Windows NT 4, and 5 for Windows NT 5.x. The low byte is the minor version number.
What exactly is version 4.01 of Windows? Frankly, I have no idea. This conditional value only appears in a few places in the C header files, mostly in the RAS declarations. I suspect it applies to a service pack, or it may represent preliminary documentation for a forthcoming service pack. Either way, it seems safer under the circumstances to assume that WINVER is 0x400. This leaves out the dwSubEntry and dwCallbackID fields and ensures that the structure will be valid under Windows NT 4 and Windows 95/98.
That's an important decision to make because, as you can see from the constant declarations, they too have changed size based on the version of Windows:
#if (WINVER >= 0x400)
#define RAS_MaxEntryName      256
#define RAS_MaxDeviceName     128
#define RAS_MaxCallbackNumber RAS_MaxPhoneNumber
#else
#define RAS_MaxEntryName      20
#define RAS_MaxDeviceName     32
#define RAS_MaxCallbackNumber 48
#endif
In their case, the size is conditional on the WINVER variable being greater than or equal to 0x400. So setting WINVER to 4.0 means that the sample will not run correctly on NT 3.x.
Based on the header files, you can create the following constant declarations in Visual Basic. The constants with the Buffer suffix are 1 greater than the base constant, since the string declarations in the RASDIALPARAMS structure are 1 byte larger than the constant value (to allow room for the NULL terminating character).
Public Const RAS_MaxEntryName = 256
Public Const RAS_MaxEntryNameBuffer = 257
Public Const RAS_MaxPhoneNumber = 128

 
< previous page page_214 next page >